import React, { Component } from "react";

class CheckBox extends Component {
  state = {
    checked: true,
  };

  fn = () => {
    console.log(11);
  };

  handChange = (e) => {
    // console.log(e.target.checked);
    this.setState({
      checked: e.target.checked,
    });
  };

  render() {
    return (
      <>
        <h2>复选框</h2>
        <input
          type="checkbox"
          onChange={this.handChange}
          checked={this.state.checked}
        />
        我已阅读此条款
        <button onClick={this.fn}>提交</button>
      </>
    );
  }
}

export default CheckBox;
